<template>
  <h3>
    使用presets添加univer表格 <el-button @click="addBd">点击添加边框</el-button>
  </h3>
  <div id="container" ref="container" class="app-container"></div>
</template>

<script setup name="Notice">
// 初始化时请注意如果项目里使用过手动组合安装univer，先删除package-lock文件，删掉package文件里的其他univer包，
// 只留下univerja/presets，安装依赖重新运行，不然会报版本冲突
import {
  createUniver,
  defaultTheme,
  LocaleType,
  merge,
} from "@univerjs/presets";
import { UniverSheetsCorePreset } from "@univerjs/presets/preset-sheets-core";
import UniverPresetSheetsCoreZhCN from "@univerjs/presets/preset-sheets-core/locales/zh-CN";
import { UniverSheetsConditionalFormattingPreset } from "@univerjs/presets/preset-sheets-conditional-formatting";
import sheetsConditionalFormattingZhCN from "@univerjs/presets/preset-sheets-conditional-formatting/locales/zh-CN";
import sheetsCoreZhCN from "@univerjs/presets/preset-sheets-core/locales/zh-CN";
import { UniverSheetsDataValidationPreset } from "@univerjs/presets/preset-sheets-data-validation";
import sheetsDataValidationZhCN from "@univerjs/presets/preset-sheets-data-validation/locales/zh-CN";
import { UniverSheetsDrawingPreset } from "@univerjs/presets/preset-sheets-drawing";
import sheetsDrawingZhCN from "@univerjs/presets/preset-sheets-drawing/locales/zh-CN";
import { UniverSheetsFilterPreset } from "@univerjs/presets/preset-sheets-filter";
import sheetsFilterZhCN from "@univerjs/presets/preset-sheets-filter/locales/zh-CN";
import { UniverSheetsHyperLinkPreset } from "@univerjs/presets/preset-sheets-hyper-link";
import sheetsHyperLinkZhCN from "@univerjs/presets/preset-sheets-hyper-link/locales/zh-CN";
import "@univerjs/presets/lib/styles/preset-sheets-core.css";
import { ref } from "vue";

import { data } from "./data";

const container = ref(null);
const sheets = ref(null);
const init = () => {
  const { univer, univerAPI } = createUniver({
    locale: LocaleType.ZH_CN,
    locales: {
      [LocaleType.ZH_CN]: merge({}, UniverPresetSheetsCoreZhCN),
    },
    theme: defaultTheme,
    presets: [
      UniverSheetsCorePreset({
        container: container.value,
      }),
      UniverSheetsConditionalFormattingPreset(),
      UniverSheetsDataValidationPreset(),
      UniverSheetsDrawingPreset(),
      UniverSheetsFilterPreset(),
      UniverSheetsHyperLinkPreset(),
    ],
  });

  univerAPI.createUniverSheet(data);
  sheets.value = univerAPI;
  // sheet.value.setRowHeights(0, 1, 50);
};
const addBd = () => {
  console.log("j");

  sheets.getActiveWorkbook().getActiveSheet();
  console.log(sheets, "sheets");
};
onMounted(() => {
  console.log("init");
  init();
});
</script>
<style lang="scss" scoped>
.app-container {
  height: 830px;
  width: 100%;
}
</style>